package 练习程序;

public class 阶梯电费 {
    public static void main(String[] args) {
        System.out.println("请输入用电量：");
        java.util.Scanner x = new java.util.Scanner(System.in);
        int a = x.nextInt();
        System.out.println("您的电费是:" + dianfei(a) + "元");

    }

    public static int dianfei(int x) {
        int y = 0;
        if (x < 0) {
            System.out.println("输入有误");
        } else if (x > 0 && x <= 100) {
            y = (int) (x * 0.3);
        } else if (x > 100 && x <= 200) {
            y = (int) (x * 0.4);
        } else if (x > 200 && x <= 300) {
            y = (int) (x * 0.5);
        } else {
            y = (int) (x * 0.8);
        }
        return y;
    }


}

